﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace jnxc.Web.ppicinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int picid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(picid);
				}
			}
		}
			
	private void ShowInfo(int picid)
	{
		jnxc.BLL.ppicinfo bll=new jnxc.BLL.ppicinfo();
		jnxc.Model.ppicinfo model=bll.GetModel(picid);
		this.lblpicid.Text=model.picid.ToString();
		this.txtcaseid.Text=model.caseid.ToString();
		this.txtstage.Text=model.stage.ToString();
		this.txtpicpath.Text=model.picpath;
		this.txtremark.Text=model.remark;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtcaseid.Text))
			{
				strErr+="案例格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtstage.Text))
			{
				strErr+="阶段前0中1后2格式错误！\\n";	
			}
			if(this.txtpicpath.Text.Trim().Length==0)
			{
				strErr+="图片地址不能为空！\\n";	
			}
			if(this.txtremark.Text.Trim().Length==0)
			{
				strErr+="备注不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int picid=int.Parse(this.lblpicid.Text);
			int caseid=int.Parse(this.txtcaseid.Text);
			int stage=int.Parse(this.txtstage.Text);
			string picpath=this.txtpicpath.Text;
			string remark=this.txtremark.Text;


			jnxc.Model.ppicinfo model=new jnxc.Model.ppicinfo();
			model.picid=picid;
			model.caseid=caseid;
			model.stage=stage;
			model.picpath=picpath;
			model.remark=remark;

			jnxc.BLL.ppicinfo bll=new jnxc.BLL.ppicinfo();
			bll.Update(model);
			jnxc.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
